var a = 100;

console.log(a.toString(2));
console.log(a.toString(16));

// 方式是进行除法，取得的余数放在最后，倒着来
var func = function (num, radix = 2) {
    var arr = [];
    while (num) {
        let remainder = num % radix;
        arr.unshift(remainder);
        num = Math.floor(num / radix);
    }
    return arr.join('');
};

console.log(func(100));
console.log(func(100, 16)); // 64
